home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util4 / bytmrk20.lha / emfloat.h < prev    next >
C/C++ Source or Header  |  1995-11-03  |  4KB  |  117 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. /*
  5. ** DEFINES
  6. */
  7. #define u8 unsigned char
  8. #define u16 unsigned short
  9. #define u32 unsigned long
  10. #define uchar unsigned char
  11. #define ulong unsigned long
  12.  
  13. #define MAX_EXP 32767L
  14. #define MIN_EXP (-32767L)
  15.  
  16. #define IFPF_IS_ZERO 0
  17. #define IFPF_IS_SUBNORMAL 1
  18. #define IFPF_IS_NORMAL 2
  19. #define IFPF_IS_INFINITY 3
  20. #define IFPF_IS_NAN 4
  21. #define IFPF_TYPE_COUNT 5
  22.  
  23. #define ZERO_ZERO                       0
  24. #define ZERO_SUBNORMAL                  1
  25. #define ZERO_NORMAL                     2
  26. #define ZERO_INFINITY                   3
  27. #define ZERO_NAN                        4
  28.  
  29. #define SUBNORMAL_ZERO                  5
  30. #define SUBNORMAL_SUBNORMAL             6
  31. #define SUBNORMAL_NORMAL                7
  32. #define SUBNORMAL_INFINITY              8
  33. #define SUBNORMAL_NAN                   9
  34.  
  35. #define NORMAL_ZERO                     10
  36. #define NORMAL_SUBNORMAL                11
  37. #define NORMAL_NORMAL                   12
  38. #define NORMAL_INFINITY                 13
  39. #define NORMAL_NAN                      14
  40.  
  41. #define INFINITY_ZERO                   15
  42. #define INFINITY_SUBNORMAL              16
  43. #define INFINITY_NORMAL                 17
  44. #define INFINITY_INFINITY               18
  45. #define INFINITY_NAN                    19
  46.  
  47. #define NAN_ZERO                        20
  48. #define NAN_SUBNORMAL                   21
  49. #define NAN_NORMAL                      22
  50. #define NAN_INFINITY                    23
  51. #define NAN_NAN                         24
  52. #define OPERAND_ZERO                    0
  53. #define OPERAND_SUBNORMAL               1
  54. #define OPERAND_NORMAL                  2
  55. #define OPERAND_INFINITY                3
  56. #define OPERAND_NAN                     4
  57.  
  58. /*
  59. ** Following already defined in NMGLOBAL.H
  60. **
  61. #define INTERNAL_FPF_PRECISION 4
  62. */
  63.  
  64. /*
  65. ** TYPEDEFS
  66. */
  67.  
  68. typedef struct
  69. {
  70.         u8 type;        /* Indicates, NORMAL, SUBNORMAL, etc. */
  71.         u8 sign;        /* Mantissa sign */
  72.         short exp;      /* Signed exponent...no bias */
  73.         u16 mantissa[INTERNAL_FPF_PRECISION];
  74. } InternalFPF;
  75.  
  76. /*
  77. ** PROTOTYPES
  78. */
  79. void SetupCPUEmFloatArrays(InternalFPF *abase,
  80.         InternalFPF *bbase, InternalFPF *cbase, ulong arraysize);
  81. ulong DoEmFloatIteration(InternalFPF *abase,
  82.         InternalFPF *bbase, InternalFPF *cbase,
  83.         ulong arraysize, ulong loops);
  84. static void SetInternalFPFZero(InternalFPF *dest,
  85.                         uchar sign);
  86. static void SetInternalFPFInfinity(InternalFPF *dest,
  87.                         uchar sign);
  88. static void SetInternalFPFNaN(InternalFPF *dest);
  89. static int IsMantissaZero(u16 *mant);
  90. static void Add16Bits(u16 *carry,u16 *a,u16 b,u16 c);
  91. static void Sub16Bits(u16 *borrow,u16 *a,u16 b,u16 c);
  92. static void ShiftMantLeft1(u16 *carry,u16 *mantissa);
  93. static void ShiftMantRight1(u16 *carry,u16 *mantissa);
  94. static void StickyShiftRightMant(InternalFPF *ptr,int amount);
  95. static void normalize(InternalFPF *ptr);
  96. static void denormalize(InternalFPF *ptr,int minimum_exponent);
  97. void RoundInternalFPF(InternalFPF *ptr);
  98. static void choose_nan(InternalFPF *x,InternalFPF *y,InternalFPF *z,
  99.                 int intel_flag);
  100. static void AddSubInternalFPF(uchar operation,InternalFPF *x,
  101.                 InternalFPF *y,InternalFPF *z);
  102. static void MultiplyInternalFPF(InternalFPF *x,InternalFPF *y,
  103.                         InternalFPF *z);
  104. static void DivideInternalFPF(InternalFPF *x,InternalFPF *y, 
  105.                         InternalFPF *z);
  106. static void LongToInternalFPF(long mylong,
  107.                 InternalFPF *dest);
  108. static int InternalFPFToString(char *dest,
  109.                 InternalFPF *src);
  110.  
  111. /*
  112. ** EXTERNALS
  113. */
  114. extern ulong StartStopwatch(void);
  115. extern ulong StopStopwatch(ulong elapsed);
  116. extern long randwc(long num);
  117.